package com.up.tcc.controler;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.up.tcc.model.PessoaBean;
import com.up.tcc.util.Conexao;

public class Familia {
	
    Connection con = new Conexao().getConnection();  
    
     public Familia(){
    	 
     }  
     
    @SuppressWarnings("static-access")
	public void Gravar() {
        //cria objeto      
    	PessoaBean pBean = new PessoaBean();      
    	
    	String sql =  "insert into pessoa_ai( nome, idade, endereco)VALUES(?,?,?)";
    	
    	try {       
    		PreparedStatement stmt = con.prepareStatement(sql);  
    		
    		stmt.setString(1, pBean.getNome());
    		stmt.setInt(2, pBean.getIdade());
    		stmt.setFloat(3, pBean.getRendaInd());
    		
    		stmt.execute(); //executa comando         
    		stmt.close();
    		System.out.println("Cadastro Realizado com Sucesso!!");
    	}catch (SQLException e) { 
    	e.printStackTrace();  
        System.out.println(e.getMessage());
        throw new RuntimeException(e);  
    	}
    }
}
